package com.kungfuhacking.wristbandpro.find.activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
import com.kungfuhacking.wristbandpro.custom.TitleBarView;
import com.kungfuhacking.wristbandpro.net.ApiService;

/**
 * 问卷调查
 * Created by Aaron on 17/5/10.
 */

public class QuestionnaireActivity extends BaseActivity {

    private WebView wv_inquire;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_webview);
        initWidget();

    }

    private void initWidget() {
        this.wv_inquire = (WebView) findViewById(R.id.wv);
        TitleBarView tbv = (TitleBarView) findViewById(R.id.tbv);

        tbv.setOnLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tbv.setTitle(getResources().getString(R.string.questionnaire));

        WebSettings settings = wv_inquire.getSettings();

        settings.setDomStorageEnabled(true);
        settings.setJavaScriptEnabled(true);

        //让webview在程序内部打开网页 而不调用系统的浏览器
        wv_inquire.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                return false;

            }
        });

        wv_inquire.loadUrl(ApiService.QUESTIONNAIRE);
        wv_inquire.setWebChromeClient(new WebChromeClient());

    }


    @Override
    public void onBackPressed() {

        if (wv_inquire.canGoBack())
            wv_inquire.goBack();
        else
            super.onBackPressed();

    }
}
